Music Object Static Methods

 Static Method Name   Short Description 
Embedding
Music.magicEmbed Embeds a non-scriptable Beatnik Player instance on a page.
Compatibility
Music.hasMinVersion Checks to see if the currently installed Beatnik Player version is equal to or higher than the version that you specify.
Music.installPlayer Launches the Beatnik Player Install Wizard in a separate window.
Music.isPlayerCompatible Performs a compatibility test for the user's installed Beatnik Player version.
Music.promptClose Closes a prompt that was opened using the Music.promptUser method.
Music.promptUser Opens a prompt window that offers the user up to two options from which to choose.
Music.requireMinPlayerVersion Lets you specify a minimum player version that is required by a module of sonification code.
Musical Notes
Music.getNoteName Returns a string value representing the symbolic note name of the MIDI note number that you specify.
Music.getNoteNumber Returns an integer value representing the MIDI note number of the symbolic note name that you specify.
General
Music.addCallbackHandler Lets you add a callback handler to the stack of callback handlers for a specified instance callback.
Music.engageAudio Allows you to engage or disengage the audio device that is used by the underlying audio engine.
Music.getAudioDevicePriority Returns an integer value, indicating the current audio device priority setting for the sonified document.
Music.getReverbType Returns an integer representing the audio engine's currently selected global reverb type.
Music.isAudioDeviceShared Returns a boolean value, indicating whether or not the Beatnik Player can share the system's audio device with other media players.
Music.isAudioEngaged Returns a boolean value, indicating whether or not the player's underlying audio engine is engaged.
Music.isAudioSupported Returns a boolean value, indicating whether or not the user's system provides audio services that are compatible with the player.
Music.kill Stops all player instances that are currently playing music on a page and disables all further sonification.
Music.onAudioEngagedChange Lets you register JavaScript code that is to be executed each time there is a change in the engaged state of the player's underlying audio engine.
Music.onEngageAudio Lets you register JavaScript code that is to be executed after each call to the Music.engageAudio static method.
Music.setAudioDevicePriority Lets you set the audio device priority for the sonified document.
Music.setGlobalMute Mutes or unmutes all sound that is playing through the audio engine.
Music.setReverbType Sets the audio engine's global reverb type that is used by the when playing back.
Music.stopAll Stops all player instances that are currently playing music on the page.

Embedding

 Music.magicEmbed

 
 CATEGORY   Static Method 
 MODULE   Music Object Core 
 Music Object Component - Basic 
 Min. Player Version   n/a 
 

The Music.magicEmbed method is identical to the magicEmbed method in every respect, excepting that the player instance that is embedded using this method is not associated with any Music Object instance.

SYNTAX    Music.magicEmbed ( EmbedLineSTR )

This method is useful on pages where you are already sourcing in the "music-object.js" file for interactive sonification, but also wish to embed non-interactive background music, or multiple player instances with control panels that let the user control playback of the files. In cases where you do not expect to script interactive control of a player instance, it is better to use the Music.magicEmbed method, since there is naturally some memory and performance overhead involved in creating a Music Object instance and there is no sense in creating a Music Object instance if you do not intend to use the scriptable methods of the Music Object class.

If your Web site makes use of interactive sonification and there is some likelihood that some pages on the site will be loading in the "music-object.js" file, then it is also appropriate to source in the "music-object.js" file on pages where there will not be any interactive sonification, just so that you can make use of the Music.magicEmbed method to embed non-interactive music. The "music-object.js" file will either be cached in from the user encountering the other pages that employed interactive sonification, or the file will load in first on a non-interactive page and cache so that subsequent loading of the interactively sonified pages is faster.

So, if you will be using the "music-object.js" file for interactive sonification on your site, don't be afraid to source the file in on pages where you wish to have non-interactive music playing. And because the parameter syntax for both the magicEmbed method and the Music.magicEmbed method is exactly the same, it is easy to upgrade your coding when you decide to use scripting to control a file that was initially embedded as a non-scriptable player instance.

The following example shows how a page using the Music.magicEmbed method can be upgraded to use the magicEmbed method. In the second block of source code, the significant changes that have been made to make the player instance scriptable are highlighted in red.

Embedding a non-scriptable player instance
<HTML><HEAD><TITLE>Non-scriptable Player Instance</TITLE></HEAD>
<BODY>

<SCRIPT SRC="correct-path-here/music-object.js"></SCRIPT>

<!-- BODY OF DOCUMENT HERE -->

<SCRIPT LANGUAGE=JavaScript><!-- //

Music.magicEmbed ('SRC="my-music-file.rmf" WIDTH=144 HEIGHT=60');

// --></SCRIPT>

</BODY></HTML>
Upgrading the code to make the player instance scriptable
<HTML><HEAD><TITLE>Non-scriptable Player Instance</TITLE></HEAD>
<BODY>

<SCRIPT SRC="correct-path-here/music-object.js"></SCRIPT>

<SCRIPT LANGUAGE=JavaScript><!-- //

myMusicObject = new Music ();

// --></SCRIPT>

<!-- BODY OF DOCUMENT HERE -->

<SCRIPT LANGUAGE=JavaScript><!-- //

myMusicObject.magicEmbed ('SRC="my-music-file.rmf" WIDTH=144 HEIGHT=60');

// --></SCRIPT>

</BODY></HTML>

Compatibility

 Music.hasMinVersion

 
 CATEGORY   Static Method 
 MODULE   Music Object Core 
 Music Object Component - Compatibility 
 Min. Player Version   n/a 
 

The Music.hasMinVersion method returns a boolean value, indicating whether or not the Beatnik Player version currently installed in the user's browser meets the minimum version you specify.

SYNTAX    Music.hasMinVersion ( MinimumVersionSTR )

RETURN VALUE    boolean

If the currently installed version is equal to or exceeds the version specified in the MinimumVersionSTR parameter, then this method will return a value of true. But, if the installed version is less than that specified in the MinimumVersionSTR parameter, then a value of false is returned.

The following table indicates the results returned by this method under several different circumstances...

Installed
Version
Static Method Call Result
1.1.7 Music.hasMinVersion ('1.0') true
1.0 Music.hasMinVersion ('1.1.7') false
1.1.7 Music.hasMinVersion ('1.1.7') true
1.3 Music.hasMinVersion ('1.3.1') false
1.3 Music.hasMinVersion ('1.3.0') true
1.3.1 Music.hasMinVersion ('1.3') true
1.3.1 Music.hasMinVersion ('2') false
1.3.1 Music.hasMinVersion ('1') true

When the minimum version string that you specify has fewer subversion places than the version string of the currently installed Beatnik Player, then all "missing" subversion places are assumed to be zero. For example, if the currently installed player version is "1.1.7" and you specify a minimum version of "1", then the minimum version will be regarded as "1.0.0" for the purpose of the comparison. Similarly, if the minimum version you specify contains more subversion places than the version string of the currently installed Beatnik Player, then the version string for the installed player will be "padded" for the sake of the comparison. For example, if the currently installed player's version string is "1.3" and the minimum version you specify is "1.3.1", then the player's version string will be padded to become "1.3.0".

So an important rule to remember with version comparison using the Music.hasMinVersion method is that a version string such as "1.3" does not encompass all "1.3.x" versions, but is seen strictly as representing version "1.3.0.0" when comparisons are made.

This method returns a false value when the user's platform and/or operating system is not supported by the Beatnik Player. Because of this, you should not indiscriminately use a false return value as an indication that "Get Beatnik" graphics or text should be written into an HTML page using document.writeln statements. Instead, you should also check the Music.clientSupported property's value in any condition that may result in Beatnik substitution code being written into an HTML page.

For example,

if (Music.clientSupported && !Music.hasMinVersion ('1.3.2')) {
   document.writeln (
      '<A HREF="javascript:Music.installPlayer ()">Please upgrade Beatnik</A>'
   );
}

For more information on using this method in conjunction with the other compatibility methods and properties, see the section Music Object Compatibility Aids.

 Music.installPlayer

 
 CATEGORY   Static Method 
 MODULE   Music Object Core 
 Music Object Component - Compatibility 
 Min. Player Version   n/a 
 

The Music.installPlayer method lets you launch the Beatnik Player Install Wizard in a separate small window that the user can optionally dismiss without it interrupting their Web browsing.

SYNTAX    Music.installPlayer ( )

The Beatnik Player Install Wizard should only be invoked as a result of a failed compatibility test using the Music.isPlayerCompatible method. If you call this method without performing an appropriate compatibility test and the user actually has the latest version of the Beatnik Player installed, then the Beatnik Player Install Wizard that opens in a separate window will show a message to this effect.

For more information on using this method in conjunction with the other compatibility methods and properties, see the section Music Object Compatibility Aids.

 Music.isPlayerCompatible

 
 CATEGORY   Static Method 
 MODULE   Music Object Core 
 Music Object Component - Compatibility 
 Min. Player Version   n/a 
 

The Music.isPlayerCompatible method lets you force Music Object to perform the compatibility test even before any attempts are made in the authoring to embed Beatnik Player instances into the page.

SYNTAX    Music.isPlayerCompatible (
    MinimumVersionSTR ,
    SilentIfInadequateBOOL ,
    ShowCompatibilityPromptBOOL
)

RETURN VALUE    boolean

This method returns a boolean value, where a value of true indicates that the user's installed Beatnik Player is compatible with the author's requirements, and a value of false indicates that the user's installed player fails to meet the author's requirements. Regardless of the author's specified version requirement, if a user does not have any version of the Beatnik Player installed, then this method always returns a false value.

This method also returns a false value when the user's platform and/or operating system is not supported by the Beatnik Player. Because of this, you should not indiscriminately use a false return value as an indication that "Get Beatnik" graphics or text should be written into an HTML page using document.writeln statements. Instead, you should also check the Music.clientSupported property's value in any condition that may result in Beatnik substitution code being written into an HTML page.

For example,

if (Music.clientSupported && !Music.isPlayerCompatible ()) {
   document.writeln ('<A HREF="javascript:Music.installPlayer ()">Get Beatnik</A>');
}

Values specified for the SilentIfInadequateBOOL and ShowCompatibilityPromptBOOL parameters will not only be used when the compatibility test is performed, but will also set the values of the Music.silentIfInadequate and Music.showCompatibilityPrompt properties, respectively. The value specified for the MinimumVersionSTR parameter may also set the value of the Music.requiredMinVersion property, if the version specified by the MinimumVersionSTR parameter is higher than the current Music.requiredMinVersion value.

For more information on using this method in conjunction with the other compatibility methods and properties, see the section Music Object Compatibility Aids.

SPECIAL VALUES
VARIATIONS
 Music.promptClose

 
 CATEGORY   Static Method 
 MODULE   Music Object Core 
 Music Object Component - Compatibility 
 Min. Player Version   n/a 
 

The Music.promptClose method lets you close a prompt window that was opened by the Music.promptUser method.

SYNTAX    Music.promptClose ( )

If there is currently no prompt window open, then this method will do nothing and will not produce any error messages.

 Music.promptUser

 
 CATEGORY   Static Method 
 MODULE   Music Object Core 
 Music Object Component - Compatibility 
 Min. Player Version   n/a 
 

The Music.promptUser static method lets you open up a non-modal dialog window to prompt the user to make a decision.

SYNTAX    Music.promptUser (
    HeadingSTR ,
    MessageSTR ,
    OkTextSTR ,
    OkJavaScriptSTR ,
    CancelTextSTR ,
    CancelJavaScriptSTR ,
    ShowStatusBarBOOL
)

The Music.promptUser method is also used within Music Object to show the compatibility prompt as well to alert the user to other problems, like Java not being enabled in Netscape Navigator. Using this method in place of the JavaScript alert or confirm function provides several benefits...

The promptUser method may be valuable in performing your own compatibility tests. If the user's configuration fails to meet your requirements, then you can use this method to alert the user. Using the method is quite easy - we will use a simple example to illustrate...

Let's say that we have created a page where both the Flash Player and Beatnik Player are to be used together to form a cohesive sonified visual experience. Since we will be relying on Flash to provide the visual element of this experience, there is hardly much sense in letting the user get only half the experience if, for some reason, Flash is not installed in their browser while the Beatnik Player is. In such cases, one will want to hold off on loading in all the music and audio media until the user has the Flash Player installed. And, in order to initiate the Flash download, the user will have to be prompted first. This is where the promptUser method comes in.

Now, traditionally, one might use the JavaScript confirm function to prompt the user for a decision. An example of this type of code is shown below. In the code sample, we are assuming that we have already determined whether or not the Flash Player is installed and have assigned the result of this check to the boolean variable "hasFlash", so the code that assigns "hasFlash" its value is not shown.

if (!hasFlash) {
   if (
      confirm (
         'Flash Not Installed!!\n' +
         '=====================\n\n' +
         'This page uses the Beatnik and' +
         ' Macromedia Flash players together\n' +
         ' to create awesome interactive content.\n\n' +
         'If you choose not to install Flash,' +
         ' you won\'t be getting the full experience.\n\n' +
         'INSTALL NOW ?'
      )
   ) {
      top.location.href = 'http://www.macromedia.com';
   }
} else {
   // code to initialize page
}

Let's examine the logic behind the above code. In the conditional statement, we are checking to see if Flash is not installed and, if this is the case, the confirm function is used to prompt the user to approve installation. If the user approves by clicking the OK button, then the statement executed by the if condition will cause the browser to redirect to Macromedia's Web site, where the user can locate and install the Flash Player. On the other hand, if the user refuses the installation by clicking on the CANCEL button, then no action is performed. Notice how the page initialization code is only performed if the user has Flash installed.

The type of output that one gets from the confirm function is not all that pretty. In fact, at the sight of these gray dialog boxes, Web surfers are inclined to panic and think that their browser may be about to crash. Also, because the confirm function always imposes an OK and CANCEL button, it forces one to state the message in the dialog box in such a way that the last sentence is always a question that can have a simple yes/no type of answer.

Example confirm dialog

So, how would we translate our code so that we could instead use Music Object's promptUser static method? Well, as explained before, the prompt window that opens does not interrupt program flow in the way that a native JavaScript alert or prompt statement does. This is because the window that is opened up is a standard browser window containing HTML and is distinct from the window that opened it - it has its own program flow. So, in order to achieve a similar kind of effect to a JavaScript alert or prompt statement, we need to organize the code in a special way. Take a look at the following example source code...

function downloadFlash () {
   Music.promptClose ();
   top.location.href = 'http://www.macromedia.com';
}

if (!hasFlash) {
   Music.promptUser (
      'Flash Not Installed!!',
      'This page uses the <B>Beatnik</B> and' +
         ' Macromedia <B>Flash</B> players' +
         ' together to create awesome interactive content.<P>If you choose not' +
         ' to install Flash, you won\'t be getting the full experience.'
      ,
      'DOWNLOAD FLASH...',
      'downloadFlash ()',
      'IGNORE',
      ''
   );
} else {
   // code to initialize page
}

We've now created a specific downloadFlash function to handle the OK action for the prompt window that will be opened up. This is necessary, because program flow is not halted by the promptUser method. We can't just wait at the spot where the promptUser method is called until the user has decided. By the very nature of the promptUser method, program flow just keeps moving forward, regardless of how long the user takes to respond.

So, the separate downloadFlash function is ready to be called at any moment if the user approves the installation of Flash. Notice how a call to the downloadFlash function is, indeed, one of the parameters in the promptUser method call. The first thing that downloadFlash function does when it is called is to close the prompt window using the Music.promptClose static method. Then, the user's browser is redirected to Macromedia's Web site, to locate and install the Flash Player.

In the prompt window below, notice how the value "Flash Not Installed!!" that we specified for the HeadingSTR parameter is also used as the title for the prompt window.

Example display of the Music.promptUser method

SPECIAL VALUES
VARIATIONS
NOTES
 Music.requireMinPlayerVersion

 
 CATEGORY   Static Method 
 MODULE   Music Object Core 
 Music Object Component - Compatibility 
 Min. Player Version   n/a 
 

The Music.requireMinPlayerVersion static method lets you specify a minimum player version that is required by a module of sonification code.

SYNTAX    Music.requireMinPlayerVersion ( MinimumVersionSTR )

Starting from Music Object version 3.3, the Music.requiredMinVersion static property is a read-only property and should not be set explicitly - the Music.requireMinPlayerVersion static method should be used instead. The Music.requireMinPlayerVersion method allows separate code modules to independently request a minimum player version, such that the highest minimum player version that is requested by all code modules will be the version used to determine if the player installed on the user's system is adequate for the content as a whole. This allows separate code modules to co-exist and declare their player dependencies in a more cooperative manner.

By default, Music Object does not require any specific version of the Beatnik Player to be installed. It is up to an author to judge based upon the features that their content makes use of, as to which minimum version should be installed in order for the content to work effectively enough. Compromises can be made, depending on how the content is authored. For instance, if the features of newer player versions are only used to enhance the experience but the authoring is not critically dependent upon these features, then an earlier version can be specified using the Music.requireMinPlayerVersion method.

In order for an author's requirement to be used when the compatibility test takes place, this method should be called before any calls are made to the Music.isPlayerCompatible or Music.magicEmbed static methods, or the magicEmbed, preloadEmbed, or stubEmbed instance methods. The best way to ensure this is to call the method in the code immediately following the SCRIPT tag that sources in the "music-object.js" file.

For example:

<SCRIPT SRC="music-object.js"></SCRIPT>

<SCRIPT LANGUAGE=JavaScript><!-- //

   Music.requireMinPlayerVersion ('1.3.2');

// --></SCRIPT>

<!-- The rest of your document follows.... -->

For more information on using this method in conjunction with the other compatibility methods and properties, see the section Music Object Compatibility Aids.

Musical Notes

 Music.getNoteName

 
 CATEGORY   Static Method 
 MODULE   Music Object Core 
 Music Object Component - Advanced 
 Min. Player Version   n/a 
 

The Music.getNoteName static method returns a string value, indicating the musical note name of the specified MIDI note number.

SYNTAX    Music.getNoteName ( NoteNumber0to127 )

RETURN VALUE    NoteNameSTR

See also the Music.getNoteNumber static method.

NOTES
 Music.getNoteNumber

 
 CATEGORY   Static Method 
 MODULE   Music Object Core 
 Music Object Component - Advanced 
 Min. Player Version   n/a 
 

The Music.getNoteNumber static method returns an integer value, indicating the MIDI note number of the specified musical note name.

SYNTAX    Music.getNoteNumber ( NoteNameSTR )

RETURN VALUE    NoteNumber0to127

The first character of the NoteNameSTR parameter must be one of the letters "A", "B", "C", "D", "E", "F", or "G". This can be followed by an optional accidental. The sharp accidental is indicated by the "#" character, and the flat accidental is indicated by a lowercase "b". Following that, and at the end of the string, should be the octave number. For example, "D#5" specifies D-sharp in the 5th octave. And "Fb3" specifies F-flat in the 3rd octave. Middle C is represented by "C4".

See also the Music.getNoteName static method.

General

 Music.addCallbackHandler

 
 CATEGORY   Static Method 
 MODULE   Music Object Core 
 Music Object Component - Advanced 
 Min. Player Version   1.3.0 
 

The Music.addCallbackHandler static method lets you add a callback handler to the stack of callback handlers for a specified static callback.

SYNTAX    Music.addCallbackHandler ( StaticCallbackTypeSTR , HandlerFunction )

VARIATIONS
NOTES
 Music.engageAudio

 
 CATEGORY   Static Method 
 MODULE   Music Object Core 
 Music Object Component - Advanced 
 Min. Player Version   1.3.0 
 

The Music.engageAudio static method allows you, at any time, to engage or disengage the audio device that is used by the Beatnik Player's underlying audio engine.

SYNTAX    Music.engageAudio ( AudioEngagedBOOL )

By default, the Beatnik Player on the Windows platform will try to occupy the system's WAV device (which is used by applications that wish to use sound). This can cause problems in Web pages that combine multiple plug-in media types that are all trying to use sound. Because of performance reasons, the Beatnik Player does not currently use Microsoft's DirectSound technology, which would let Beatnik share the system's sound resources with other applications that were written to use DirectSound. DirectSound is also not universally installed on Windows systems, and is not universally used by other audio applications.

The Music.engageAudio method gives authors a way to "free up" the WAV device from Beatnik so that other plug-in media types can play sound. This approach does, however, require some carefully thought-out scripting. The method takes a boolean parameter indicating whether the audio is to be engaged or not. If you specify a value of false then the audio will be disengaged. And if you specify a value of true then the audio will be reengaged. This method is not applicable on the Mac platform where the built-in SoundManager provides the services necessary to allow multiple applications to be using the system's sound resources at the same time.

NOTES
 Music.getAudioDevicePriority

 
 CATEGORY   Static Method 
 MODULE   Music Object Core 
 Music Object Component - Advanced 
 Min. Player Version   2.1.0 
 

The Music.getAudioDevicePriority static method returns an integer value, indicating the current audio device priority setting for the sonified document.

SYNTAX    Music.getAudioDevicePriority ( )

RETURN VALUE    AudioDevicePriority0to3

Audio device priority for a sonified document can be set using the Music.setAudioDevicePriority static method.

NOTES
 Music.getReverbType

 
 CATEGORY   Static Method 
 MODULE   Music Object Core 
 Music Object Component - Advanced 
 Min. Player Version   1.0.0 
 

The Music.getReverbType static method returns an integer value, indicating the current global reverb type that is set for the underlying Beatnik audio engine.

SYNTAX    Music.getReverbType ( )

RETURN VALUE    ReverbType1to11

Reverb type can be set by a MIDI controller message within an RMF or MIDI file, but can also be set via scripting using the Music.setReverbType static method.

NOTES
 Music.isAudioDeviceShared

 
 CATEGORY   Static Method 
 MODULE   Music Object Core 
 Music Object Component - Advanced 
 Min. Player Version   2.1 
 

The Music.isAudioDeviceShared static method returns a boolean value, indicating whether or not the Beatnik Player can share the system's audio device with other media players.

SYNTAX    Music.isAudioDeviceShared ( )

RETURN VALUE    boolean

A value of true indicates that the system's audio device can be shared, while a value of false indicates that the audio device cannot be shared. For a clearer understanding of how the Music.isAudioDeviceShared method relates to other methods that can be used to manage and monitor the engaged state behavior of the player's underlying audio engine, consult the section Audio Device Contention Manager.

The "Best Guess" Situation

Because this method relies upon the cooperation of player versions 2.1 and higher, the method will be unable to determine conclusively whether or not the system's audio device can be shared if the version of the installed player is earlier than 2.1, or there is no player installed. In such cases, the Music.isAudioDeviceShared method will return a "best guess" value based upon the user's operating system. The value false will be returned for Windows 95, Windows 98, and versions of Window NT earlier than 5.0, and the value true will be returned for all other operating systems.

An Example

In order for the Music.isAudioDeviceShared method to return reliable results, this method should only be called after at least one Music Object instance has been embedded and is ready. The following sample code template shows how to correctly use this method...

<SCRIPT SRC="music-object.js"></SCRIPT>

<SCRIPT LANGUAGE=JavaScript><!-- //

function checkAudioDeviceShared () {
   if (!Music.isAudioDeviceShared ()) {
      // code to handle systems that cannot mix audio from multiple applications
   }
}

music = new Music ();
music.onReady (checkAudioDeviceShared);
music.stubEmbed ('stub.rmf');

/*** Your Sonification Code Follows ***/

// --></SCRIPT>

NOTES
 Music.isAudioEngaged

 
 CATEGORY   Static Method 
 MODULE   Music Object Core 
 Music Object Component - Advanced 
 Min. Player Version   2.1 
 

The Music.isAudioEngaged static method returns a boolean value, indicating whether or not the player's underlying audio engine is engaged.

SYNTAX    Music.isAudioEngaged ( )

RETURN VALUE    boolean

A value of true indicates that the audio engine is engaged, while a value of false indicates that the audio engine is disengaged. One common way to use this method is in a handler for the onAudioEngagedChange static callback. Because the onAudioEngagedChange callback is triggered when the audio engine becomes engaged as well as when it becomes disengaged, the Music.isAudioEngaged method can be used at the time that the callback is triggered to determine what the new engaged state of the audio engine is.

The Music.isAudioEngaged method is only supported for player versions 2.1 and higher, and the primary way that the audio engine would switch from being engaged to being disengaged (or vice versa) in these player versions would be as a result of the Audio Device Contention Manager that is built into these versions. For a clearer understanding of how the Music.isAudioEngaged method relates to other methods that can be used to manage and monitor the engaged state behavior of the player's underlying audio engine, consult the section Audio Device Contention Manager.

NOTES
 Music.isAudioSupported

 
 CATEGORY   Static Method 
 MODULE   Music Object Core 
 Music Object Component - Advanced 
 Min. Player Version   2.1 
 

The Music.isAudioSupported method returns a boolean value, indicating whether or not the user's system provides audio services that are compatible with the player.

SYNTAX    Music.isAudioSupported ( )

RETURN VALUE    boolean

In most cases, if a system has sound hardware (such as a soundcard, or a sound chip that is integrated into the motherboard), then the Music.isAudioSupported method will return the value true. That said, however, there may be a very small number of systems where sound hardware is installed but the sound hardware's software drivers are incompatible with the Beatnik Player (or some aspect of the operating system's underlying audio services that are used by the Beatnik Player).

Denying Access to Content

Certain types of sonified content may rely so heavily upon the audio features of the Beatnik Player that it may not be worth letting users experience the content if their system has no audio support. In fact, allowing users to enter music remixing applications, for example, when their system doesn't even have audio support may just be a source of confusion for such users, as well as a source of technical support e-mails or phonecalls for you. The Music.isAudioSupported method can be used to deny a user access to such content if their system has no audio support.

Benefit of the Doubt

If the Music.isAudioSupported method is called before at least one Music Object instance has been embedded and is ready, or a version of the player earlier than version 2.1 is installed, or there is no player installed at all, then the method will return the value true. This is somewhat of a "benefit of the doubt" approach, where the user's system is assumed to have audio support unless it can be determined conclusively, using the player, that their system does not have audio support.

An Example

In order for the Music.isAudioSupported method to return reliable results, this method should only be called after at least one Music Object instance has been embedded and is ready. The following sample code listing shows one example of how this method can be used correctly to filter out users who attempt to experience sonified content when their system has no audio support.

<SCRIPT SRC="music-object.js"></SCRIPT>

<SCRIPT LANGUAGE=JavaScript><!-- //

function gotoSonifiedContent () {
   document.location.href = 'sonified.html';
}

function gotoApologyPage () {
   document.location.href = 'sorry.html';
}

function checkAudioSupported () {
   Music.isAudioSupported () ? gotoSonifiedContent () : gotoApologyPage ();
}

if (!Music.hasPlayer) {
   gotoApologyPage ();
} else if (Music.clientPlatform != 'Win32') {
   gotoSonifiedContent ();
} else if (Music.hasMinVersion ('2.1')) {
   music = new Music ();
   music.onReady (checkAudioSupported);
   music.stubEmbed ('stub.rmf');
} else {
   Music.promptUser (
      'System Supports Audio?',
      'With the version of the Beatnik Player that is installed in ' +
         'your browser, it is not possible to automatically determine ' +
         'if your system supports audio.<P>This sonified content ' +
         'requires that your system have audio hardware and may not ' +
         'work correctly or may even crash your browser if sound ' +
         'hardware is not installed.<P>' +
         'Does your system support audio?',
      'YES','gotoSonifiedContent ()',
      'NO','gotoApologyPage ()'
   );
}

/*** Your Sonification Code Follows ***/

// --></SCRIPT>

In this example, it is assumed that an HTML page "sorry.html" will attempt to console users who do not have the Beatnik Player installed or who's systems do not have audio support. Any user who's system meets the requirements for the sonified content will be directed to the actual sonified HTML page "sonified.html". In cases where it is not possible to automatically detect if the user's system has audio support, the user is prompted to make that judgement for themselves and, based upon the response, the user will either be directed to the "sorry.html" page or the "sonified.html" page.

Notice how the Music.isAudioSupported method is only called if the function "checkAudioSupported" is called. This function is set up as a handler for the onReady callback of the Music Object instance "music", and this instance is only created if the user has the player installed and they are running a Windows system. The reason for this shortcut is that the MacOS and WebTV platforms have built-in audio hardware that is supported by Beatnik and, therefore, the problem of having no audio support is almost certain to occur only on some Windows systems. So, the call to the Music.isAudioSupported method is not really necessary on systems other than Windows systems.

NOTES
 Music.kill

 
 CATEGORY   Static Method 
 MODULE   Music Object Core 
 Music Object Component - Advanced 
 Min. Player Version   1.0.0 
 

The Music.kill static method lets you stop all player instances that are currently playing music on a page and disable all further sonification, all in a single step.

SYNTAX    Music.kill ( )

In effect, the Music.kill static method stops all player instances on the page in much the same way as the Music.stopAll static method, and then disables all further sonification on the page by setting the Music.enabled static property to false.

This method may be called even before player instances have been embedded on the page. In this event, the sonification would be disabled and no instances would be embedded as a result of calls to the Music Object API's various embedding methods (magicEmbed, stubEmbed, preloadEmbed, and Music.magicEmbed), unless some code set the Music.enabled static property to true again before the embedding methods were called. Because the Music.kill method disables sonification by setting the Music.enabled static property to false, it would be possible to re-enable sonification after this method has been called, simply by executing the statement Music.enabled = true.

 Music.onAudioEngagedChange

 
 CATEGORY   Static Method 
 MODULE   Music Object Core 
 Music Object Component - Advanced 
 Min. Player Version   2.1 
 

The Music.onAudioEngagedChange static method lets you register JavaScript code that is to be executed each time there is a change in the engaged state of the player's underlying audio engine.

SYNTAX    Music.onAudioEngagedChange ( HandlerJavaScriptSTR )

The onAudioEngagedChange static callback is triggered each time there is a change in the audio engaged state of the player's underlying audio engine. At the time that the onAudioEngagedChange callback is triggered, the current engaged state of the audio engine can be determined using the Music.isAudioEngaged static method.

The onAudioEngagedChange callback is only supported for player versions 2.1 and higher, and the primary way that the audio engine would switch from being engaged to being disengaged (or vice versa) in these player versions would be as a result of the Audio Device Contention Manager that is built into these versions. For a clearer understanding of how the Music.onAudioEngagedChange method relates to other methods that can be used to manage and monitor the engaged state behavior of the player's underlying audio engine, consult the section Audio Device Contention Manager.

VARIATIONS
NOTES
 Music.onEngageAudio

 
 CATEGORY   Static Method 
 MODULE   Music Object Core 
 Music Object Component - Advanced 
 Min. Player Version   2.1 
 

The Music.onEngageAudio static method lets you register JavaScript code that is to be executed after each call to the Music.engageAudio static method.

SYNTAX    Music.onEngageAudio ( HandlerJavaScriptSTR )

The onEngageAudio static callback is triggered after each call to the Music.engageAudio static method. At the time that this callback is triggered, the value specified in the most recent call to the Music.engageAudio method is reflected in the Music.embedDefaults.AUDIOENGAGED static property (see the reference section for the Music.embedDefaults static property). Registering a handler for the onEngageAudio callback can be a convenient way to monitor the activity of the Auto Disengage extension.

VARIATIONS
NOTES
 Music.setAudioDevicePriority

 
 CATEGORY   Static Method 
 MODULE   Music Object Core 
 Music Object Component - Advanced 
 Min. Player Version   2.1.0 
 

The Music.setAudioDevicePriority static method lets you set the audio device priority for the sonified document.

SYNTAX    Music.setAudioDevicePriority ( AudioDevicePriority0to3 )

The current audio device priority setting for a sonified document can be queried using the Music.getAudioDevicePriority static method.

NOTES
 Music.setGlobalMute

 
 CATEGORY   Static Method 
 MODULE   Music Object Core 
 Music Object Component - Advanced 
 Min. Player Version   1.3.0 
 

The Music.setGlobalMute static method lets you set the global mute state for the underlying Beatnik audio engine.

SYNTAX    Music.setGlobalMute ( MuteStateBOOL )

Using the Music.setGlobalMute method has the same effect as if the user were to click the global mute button that appears on the top portion of the player's control panel when it is in SYSTEM display. The global mute state affects all player instances that are embedded in all frames of all browser windows that may currently be open. This method takes a boolean parameter representing the mute state you would like to invoke. If you specify a value of true, then all players will become silent. And if you specify a value of false, then the global mute state will be disabled.

NOTES
 Music.setReverbType

 
 CATEGORY   Static Method 
 MODULE   Music Object Core 
 Music Object Component - Advanced 
 Min. Player Version   1.0.0 
 

The Music.setReverbType static method lets you set the global reverb type for the underlying Beatnik audio engine.

SYNTAX    Music.setReverbType ( ReverbType1to11 )

See the ReverbType1to11 parameter for a list of the Beatnik Player's possible reverb types.

NOTES
 Music.stopAll

 
 CATEGORY   Static Method 
 MODULE   Music Object Core 
 Music Object Component - Advanced 
 Min. Player Version   1.0.0 
 

The Music.stopAll static method lets you stop all Music Object instances that are currently playing music on the page.

SYNTAX    Music.stopAll ( )

Only instances that exist in the same document that contains the "music-object.js" file will be stopped - other sonified frames or windows will not be affected by this method.